home *** CD-ROM | disk | FTP | other *** search
/ DC Comics: Essential Coll…ditions & Graphic Novels / DC Comics: Essential Collected Editions & Graphic Novels.iso / pc / scripts / grabdata_scripts.js next >
Encoding:
Text File  |  2004-04-27  |  1.4 KB  |  39 lines

  1.  
  2.  
  3. //************************************************************
  4. // This example is from JavaScript: The Definitive Guide, 3rd Edition.
  5. // That book and this example were Written by David Flanagan.
  6. // They are Copyright (c) 1996, 1997, 1998 O'Reilly & Associates.
  7. // This example is provided WITHOUT WARRANTY either expressed or implied.
  8. // You may study, use, modify, and distribute it for any purpose,
  9. // as long as this notice is retained.
  10. //<!-- Modified by:  Kenneth C. Devoe, WildStorm Productions -->
  11.  
  12. /*
  13.  * Function getArgs() parses comma-separated name=value argument pairs from
  14.  * the query string of the URL. It stores the name=value pairs in 
  15.  * properties of an object and returns that object.
  16.  */
  17. function getArgs()
  18. {
  19.   var args = new Object();                   // Create the object.
  20.   var query = location.search.substring(1);  // Get query string.
  21.   var pairs = query.split("&");              // Break at ampersand.
  22.   for(var i = 0; i < pairs.length; i++)
  23.   {
  24.     var pos = pairs[i].indexOf('=');           // Look for "name=value".
  25.     if (pos == -1){
  26.       continue;                                 // If not found, skip.
  27.     }
  28.     var argname = pairs[i].substring(0,pos);  // Extract the name.
  29.     var value = pairs[i].substring(pos+1);    // Extract the value.
  30.     args[argname] = unescape(value);          // Store as a property.
  31.   }
  32.   return args;                              // Return the object.
  33. }
  34.  
  35.  
  36. //------------------------------
  37.  
  38.  
  39.